package com.hzhr.iot.device.controller;

import com.hzhr.iot.core.annotation.ApiImplicitInternalParams;
import com.hzhr.iot.core.annotation.Author;
import com.hzhr.iot.core.exception.ServiceException;
import com.hzhr.iot.device.controller.base.BaseController;
import com.hzhr.iot.device.model.regulatorDevice_implRecord.RegulatorDevice_ImplRecordGetModel;
import com.hzhr.iot.device.model.regulatorDevice_monitor.RegulatorDevice_MonitorGetModel;
import com.hzhr.iot.device.service.RegulatorDevice_ImplRecordService;
import com.hzhr.iot.device.service.RegulatorDevice_MonitorService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.util.Map;

@Api(tags = "RegulatorDevice_ImplRecord", description = "调压设备下的实施档案")
@RestController
@RequestMapping(value = "")
public class RegulatorDevice_ImplRecordController extends BaseController {
    @Autowired
    RegulatorDevice_ImplRecordService regulatorDevice_implRecordService;

    //region /regulator-devices/{regulatorDeviceId}/impl-records GET
    //region swagger响应码 : get
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功"),
    })
    //endregion
    //region swagger说明 : get
    @ApiOperation(value="查询调压设备的实施档案", notes="查询调压设备的实施档案  \n简介 : 查询调压设备的实施档案  \n步骤 :  \n1. 查询调压设备 :  \n查询COLLECT_DEVICE对象regulator_1，  \n查询规则如下：  \n          (1) COLLECT_DEVICE.ID == 路径参数regulatorDeviceId;  \n          (2) COLLECT_DEVICE.IS_VALID == '1'；  \n如果regulator_1不存在，抛出异常201；  \n2. 查询调压设备的下的监控设备 :  \n查询IOT_DEVICE对象集合monitors_1,  \n查询规则如下：  \n          (1) IOT_DEVICE.COLLECT_DEVICE_ID == regulator_1.ID;  \n          (2) IOT_DEVICE.IS_VALID == '1';  \n如果monitors_1.size == 0, 抛出异常202；  \n3. 查询监控设备的实施档案 :  \n查询IMPL_RECORD对象集合implRecords_1及总数,  \n查询规则如下：  \n          (1) IMPL_RECORD.IOT_DEVICE_CODE in monitors_1.CODE  \n          (2) IMPL_RECORD.IS_VALID = '1'  \n4. 返回信息  \n根据条件参数、implRecords_1及总数生成RegulatorDevice_ImplRecordGetModel对象result并返回，  \nRegulatorDevice_ImplRecordModel与IMPL_RECORD的对应关系如下：  \n          (1) RegulatorDevice_ImplRecordModel.iotDeviceCode => IMPL_RECORD.IOT_DEVICE_CODE;  \n          (2) RegulatorDevice_ImplRecordModel.gasUserName => IMPL_RECORD.GAS_USER_NAME;  \n          (3) RegulatorDevice_ImplRecordModel.gasUserAddress => IMPL_RECORD.GAS_USER_ADDRESS;  \n          (4) RegulatorDevice_ImplRecordModel.implementer => IMPL_RECORD.IMPLEMENTER;  \n          (5) RegulatorDevice_ImplRecordModel.implementTime => IMPL_RECORD.IMPLEMENT_TIME;  \n          (6) RegulatorDevice_ImplRecordModel.beforeImg => IMPL_RECORD.BEFORE_IMG;  \n          (7) RegulatorDevice_ImplRecordModel.afterImg => IMPL_RECORD.AFTER_IMG;  \n",produces = "application/json")
    //endregion
    //region swagger参数 : get
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "令牌",required = true, dataType = "string", paramType = "header"),

            @ApiImplicitParam(name = "regulatorDeviceId", value = "调压设备编号",required = true, dataType = "int", paramType = "path"),

            @ApiImplicitParam(name = "show", value = "展示形式 one:展示一个,list:展示列表,null(空值):不展示", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "show_total", value = "是否展示总数", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
    })
    @ApiImplicitInternalParams({
            @ApiImplicitParam(name = "_token", value = "令牌",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-id", value = "用户编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-code", value = "用户代码",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-name", value = "用户名",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-company-id", value = "公司编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-dept-id", value = "部门编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-type", value = "用户类型(关联: common_service.options.code, typeCode = 'USER_TYPE')",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-transaction-id", value = "交易流水号",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-transaction-type", value = "交易类型",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-access-mode", value = "访问模式 0:一般 1:全局",defaultValue = "0", required = false, dataType = "int", paramType = "header"),

            @ApiImplicitParam(name = "_show", value = "展示形式 one:展示一个,list:展示列表,null(空值):不展示", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "_show_total", value = "是否展示总数", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
    })
    //endregion
    //region 请求 : get
    @RequestMapping(value = "/regulator-devices/{regulatorDeviceId}/impl-records", method = RequestMethod.GET)
    //endregion
    @Author
    public ResponseEntity<RegulatorDevice_ImplRecordGetModel> get(@PathVariable("regulatorDeviceId")Integer regulatorDeviceId, @RequestParam @ApiIgnore Map<String, Object> query) throws ServiceException {
        RegulatorDevice_ImplRecordGetModel responseBody = regulatorDevice_implRecordService.get(initHeader(), regulatorDeviceId,query);
        return new ResponseEntity<>(responseBody, HttpStatus.OK);
        //endregion
    }
    //endregion

}


































































































































































